// 实现分页,能实现男女个数和总数的统计
// ,能统计出（小于18） 和 18-45 和 45岁以上的人数
let mysql = require("mysql");
let conne = mysql.createConnection({host:"127.0.0.1",user:"root",password:"123456",database:"dome"});
conne.connect();

let aa = 1;
let bb = 3;
conne.query("SELECT * FROM dly LIMIT "+(aa-1)*bb+","+bb,(err,data)=>{
    console.log("第"+aa+"页");
    console.log(data);
})
conne.query("select count(*) as '男生个数' from dly where sex='男'",(err,data)=>{
    console.log("————————————————————男生个数————————————————————");
    console.log(data);
})
conne.query("select count(*) as '女生个数' from dly where sex='女'",(err,data)=>{
    console.log("————————————————————女生个数————————————————————");
    console.log(data);
})
conne.query("select count(*) as '男女总数' from dly ",(err,data)=>{
    console.log("————————————————————男女总数————————————————————");
    console.log(data);
})
conne.query("SELECT COUNT(*) as '小于18岁的人数' FROM dly where dly.avg<18",(err,data)=>{
    console.log("—————————————————————小于18周岁人数为————————————————————");
    console.log(data);
})
conne.query("SELECT COUNT(*) as '18-45的人数' FROM dly where dly.avg>18 and dly.avg<45",(err,data)=>{
    console.log("—————————————————————18-45周岁人数为————————————————————");
    console.log(data);
})
conne.query("SELECT COUNT(*) as '45岁以上的人数' FROM dly where dly.avg<45",(err,data)=>{
    console.log("—————————————————————45岁周岁以上人数为————————————————————");
    console.log(data);
})
conne.end();